<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <script>
        function validatefname(){
            var x=document.forms['myForm']['fname'].value;
            if(x==null||x==''){
                alert('姓必须填写');
                return false
            }
            return true;
        };

        function validatesname(){
            var x=document.forms['myForm']['sname'].value;
            if(x==null||x==''){
                alert('名必须填写');
                return false
            }
            return true;
        }
        function validatemail(){
            var x=document.forms['myForm']['email'].value;
            var atpos=x.indexOf('@');
            var dotpos=x.lastIndexOf('.');
            if(x==null||x==''){
                alert('邮件必须填写');
                return false
            };
            if(atpos<1||dotpos<atpos+2||dotpos+2>=x.length){
                alert('不是一个有效的e-mail地址');
                return false;
            }
            return true;
        }
        function change(){
            if(validatefname()&&validatesname()&&validatemail()){
                alert('恭喜你，注册成功！');
                return true
            }
            else {
                alert('对不起登陆失败');
                return false;
            }

        }
    </script>
</head>
<body>
<div>
    <form name="myForm" method="post" action="./HtmlData.php" onsubmit="return change()">
        <input type="text" name="fname" ><br>
        <br>
        <input type="text" name="sname" ><br>
        <br>
        <input type="text" name="email" ><br>
        <br>
        <input type="submit">
    </form>


</div>

</body>
</html>